package com.yupi.shortchain.controller;

import com.yupi.shortchain.annotation.BlackListInterceptor;
import com.yupi.shortchain.common.BaseResponse;
import com.yupi.shortchain.common.ResultUtils;
import com.yupi.shortchain.model.dto.user.UserLoginRequest;
import com.yupi.shortchain.service.impl.RateLimitServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RRateLimiter;
import org.redisson.api.RateIntervalUnit;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {


    @GetMapping("/limit")
    @BlackListInterceptor(key = "default",rateLimit = 11,protectLimit = 3,fallbackMethod = "Error")
    public BaseResponse<String> testRateLimit(String acc, String pwd) {
        log.info("模拟登录用户账号:{}",acc);
        return ResultUtils.success(acc);
    }

    public void Error(){
        log.error("黑子你被禁了！！！！");
    }
}
